package com.shushan.util;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.PopupWindow;

import com.shushan.shushanbao.R;

/**
 * @ClassName: PopupWindowUtil
 * @Desciption: //PopupWindow封装工具类
 * @author: zhangshihao
 * @date: 2018-05-28
 */
public class PopupWindowUtil {

    public static PopupWindow showShareWechatPopupWindow(Context context, View.OnClickListener listener,View contentView){
        PopupWindow sharePopupWindow = new PopupWindow(context);
        sharePopupWindow.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
        sharePopupWindow.setHeight(ToolUtils.dip2px(context,145f));
        sharePopupWindow.setBackgroundDrawable(null);
        sharePopupWindow.setOutsideTouchable(true);
        sharePopupWindow.setContentView(LayoutInflater.from(context).inflate(R.layout.popup_share_to_wechat,null,false));
        sharePopupWindow.getContentView().findViewById(R.id.tv_cancel).setOnClickListener(listener);
        sharePopupWindow.getContentView().findViewById(R.id.iv_wechat_share_friend).setOnClickListener(listener);
        sharePopupWindow.getContentView().findViewById(R.id.iv_wechat_share_friends_circle).setOnClickListener(listener);
        sharePopupWindow.showAtLocation(contentView, Gravity.BOTTOM,0,0);
        return sharePopupWindow;
    }

    public static PopupWindow showCoverPopupWindow(Context context,View contentView){
        PopupWindow coverPopup = new PopupWindow(context);
        coverPopup.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
        coverPopup.setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
        coverPopup.setBackgroundDrawable(null);
        coverPopup.setContentView(LayoutInflater.from(context).inflate(R.layout.popup_cover,null,false));
        coverPopup.showAtLocation(contentView,Gravity.CENTER,0,0);
        return coverPopup;
    }

}
